package com.juku2024.juku.db.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.juku2024.juku.db.entity.FavoriteEntity

@Dao
interface FavoriteDao {

    @Query("SELECT * FROM favorite ORDER BY data DESC")
    fun queryFavorites(): LiveData<List<FavoriteEntity>>

    @Query("SELECT * FROM favorite ORDER BY data DESC")
    fun queryFavoriteList(): List<FavoriteEntity>?

    @Query("SELECT * FROM favorite WHERE videoId=:moveId")
    fun queryFavorite(moveId: Long): FavoriteEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(favorite: FavoriteEntity)

    @Query("DELETE FROM favorite")
    fun deleteAll()

    @Delete
    fun delete(favorite: FavoriteEntity)

    @Query("DELETE FROM favorite WHERE videoId=:moveId")
    fun delete(moveId: Long)

    @Delete
    fun delete(entities: List<FavoriteEntity>): Int
}